package com.lzj.server.constant.enums;

import lombok.Getter;

/**
 *  日志类型枚举
 */
@Getter
public enum LogTypeEnum {

    LIKE("LIKE", "点赞"),
    COMMENT("COMMENT", "评论"),
    COLLECT("COLLECT", "收藏"),
    FOLLOW("FOLLOW", "关注"),
    UNFOLLOW("UNFOLLOW", "取消关注"),
    SHARE("SHARE", "分享"),
    VIEW("VIEW", "浏览"),
    LOGIN("LOGIN", "登录"),
    REGISTER("REGISTER", "注册"),
    DOWNLOAD("DOWNLOAD", "下载");

    private final String code;
    private final String description;

    LogTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 通过 code 获取枚举
     */
    public static LogTypeEnum fromCode(String code) {
        for (LogTypeEnum type : values()) {
            if (type.code.equalsIgnoreCase(code)) {
                return type;
            }
        }
        return null;
    }

    /**
     * 判断 code 是否有效
     */
    public static boolean isValid(String code) {
        return fromCode(code) != null;
    }
}
